﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace DDS.IoT.DJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var ok = false;
            do
            {
                Os2Driver driver = new Os2Driver();
                driver.OnPushData += OnPushData;
                Console.Write("请输入串口号：");
                var port = Convert.ToInt32(Console.ReadLine());
                ok=driver.Init(port);
                ok = driver.Open();
                if(ok)
                    Console.WriteLine("打开成功，重量监听中...");
            } while (!ok);
            Console.ReadLine();
        }

        private static void OnPushData(string id, dynamic weight)
        {
            Console.WriteLine(DateTime.Now.ToString()+ ":" + weight);
        }

    }
}
